home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.11 Nov 90 / FKEY Source Code / Selection Sort / Display Error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-02  |  1.9 KB  |  69 lines  |  [TEXT/KAHL]

  1. #include "ToolSort.h"
  2. /*=========================================================================
  3. Module:        DisplayError
  4.  
  5. Purpose:    Display the error messages associated with err. 
  6.             
  7. returns:                
  8.  
  9. Functional Details:    
  10.  
  11.             If alert resources are not available just beep and exit.
  12.             else display error messages.
  13.  
  14. =========================================================================*/
  15.  
  16. DisplayError(err)
  17.     unsigned int err;
  18.     {
  19.     int     i;                /* index counter */
  20.     int     index[9];        /* index to diagnostics */    
  21.     int     s;                /* shift counter */
  22.     Handle    h1, h2;
  23.     long     maxmem;
  24.     long    grow;
  25.     
  26.     static char *diag[9];
  27.     
  28.     diag[0] = "";                                              /*No_Error*/
  29.     diag[1] = "\pSelection must end with a carriage return."; /*End_Error*/
  30.     diag[2] = "\pNo selection of type 'TEXT' in scarp.";      /*Type_Error*/
  31.     diag[3] = "\pNot enough memory.";                          /*Memory_Error*/
  32.     diag[4] = "\pNil Handle Error.";                          /*Nil_Hand_Error*/
  33.     diag[5] = "\pNo selection, scrap empty.";                  /*Empty_Error*/
  34.     diag[6] = "\pA system error, probably relating to the filing system."; /*Sys_Error*/
  35.     diag[7] = "\pError writing desk scrap.";                  /*Scrap_Error*/
  36.     diag[8] = "\pError writing writing TEScrap.";              /*TEScrap_Error*/
  37.                     
  38.     h1 = GetResource('ALRT', alertID);    /* Check for resource load error */
  39.     h2 = GetResource('DITL', alertID);    
  40.     if ( h1!=NIL && h2!=NIL )
  41.         {
  42.         for (s=0, i=0; s<9; s++)
  43.             {
  44.             index[s] = 0;            /* initialize index arry to zero */
  45.             if ( 0x0001 & err )
  46.                 {
  47.                 index[i] = s+1;        /* set index array to index of diagnostics */
  48.                 i++;
  49.                 }
  50.             err >>= 1;                /* shift err 1 bit to the right */
  51.             }
  52.         InitCursor();
  53.         ParamText(diag[index[0]],diag[index[1]],
  54.                             diag[index[2]],diag[index[3]]);
  55.         StopAlert( alertID, NIL );
  56.         }
  57.     else
  58.         {
  59.         if ( h1 != NIL )
  60.             ReleaseResource( h1 );
  61.         if ( h2 != NIL )
  62.             ReleaseResource( h2 );
  63.             
  64.         maxmem = MaxMem(&grow);
  65.         if ( maxmem > 500L )
  66.             SysBeep( 4 );        /* SysBeep needs memory to work with */
  67.         }
  68.     }
  69.